package com.gopay.common.domain.ep;

import com.gopay.common.cipher.utils.SensitiveInfoUtils;
import com.gopay.common.domain.BaseEntity;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "EP_CARD_STATUS_SEC")
public class EpCardStatus extends BaseEntity {
    public static final String STATUS_NORMAL = "00";
    public static final String STATUS_FREEZE = "01";
    public static final int CERT_NO_ERR_MAX = 5;
    public static final int SMS_ERR_MAX = 5;
    public static final int PAY_ERR_MAX = 3;

    private Long id;
    private String cardNo;
    private String status;
    private Integer smsErrNum;
    private Integer certNoErrNum;
    private Integer payErrNum;
    private Date lastUpdateTime;
    private Date createTime;

    @Id
    @SequenceGenerator(name = "EP_CARD_STATUS_SEC_SEQ_GENERATOR", sequenceName = "EP_CARD_STATUS_SEC_SEQ", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EP_CARD_STATUS_SEC_SEQ_GENERATOR")
    @Column(name = "ID")
    public Long getId() {
        return id;
    }

    @Column(name = "CARD_NO", nullable = false)
    public String getCardNo() {
        this.cardNo = SensitiveInfoUtils.autoReencrypt(this.cardNo);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.cardNo);
    }

    @Column(name = "STATUS", nullable = false)
    public String getStatus() {
        return status;
    }

    @Column(name = "SMS_ERR_NUM", precision = 1, scale = 0, nullable = false)
    public Integer getSmsErrNum() {
        return smsErrNum;
    }

    @Column(name = "CERT_NO_ERR_NUM", precision = 1, scale = 0, nullable = false)
    public Integer getCertNoErrNum() {
        return certNoErrNum;
    }

    @Column(name = "PAY_ERR_NUM", precision = 1, scale = 0, nullable = false)
    public Integer getPayErrNum() {
        return payErrNum;
    }

    @Column(name = "LAST_UPDATE_TIME", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    @Column(name = "CREATE_TIME", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = SensitiveInfoUtils.smartEncryptWithCheck(cardNo);
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public void setSmsErrNum(Integer smsErrNum) {
        this.smsErrNum = smsErrNum;
    }

    public void setCertNoErrNum(Integer certNoErrNum) {
        this.certNoErrNum = certNoErrNum;
    }

    public void setPayErrNum(Integer payErrNum) {
        this.payErrNum = payErrNum;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

}
